package tbs.framework.sql.interfaces.impls

import tbs.framework.log.ILogger
import tbs.framework.log.annotations.AutoLogger
import tbs.framework.sql.config.SqlConfig
import tbs.framework.sql.logger.ISqlLogger
import tbs.framework.sql.model.SqlRuntimeStatus

/**
 * 通过 SimpleSqlLogger 实现 ISqlLogger 接口
 * 适用AutoLogger实现的Sql日志记录器
 */
class SimpleSqlLogger : ISqlLogger {

    @AutoLogger(factory = SqlConfig.SQL_LOG_FACTORY_BEAN_NAME)
    lateinit var logger: ILogger;

    override fun log(sqlRuntimeStatus: SqlRuntimeStatus) {
        logger.info("Execute SQL: ${sqlRuntimeStatus.prepareSql}\nCost Time: ${sqlRuntimeStatus.executeTime}ms")
    }
}